//
//  Log.swift
//  VPai
//
//  Created by devel on 16/9/9.
//  Copyright © 2016年 viatech. All rights reserved.
//

import Foundation
import tcp2usb
/**
 *
 *  Uage: 
 *  define a TAG const in your swift file, not in the class
 * private let TAG = "MyClassLog"
 * then 
 *  Log.info(TAG, "hello, %d, %@", 1, "world")
 *  %@ can be used to print NSObject.
 */

class Log{
    
    static func verbose(tag: String, msg: String){
        NSLog("\(tag) : \(msg)")
    }
    static func verbose(tag: String, _ format : String, _ args: CVarArgType...){
        let s = String(format: format, arguments: args)
        NSLog("\(tag): \(s)")
    }
    
    static func info(tag: String, msg: String){
        NSLog("\(tag) : \(msg)")
        HAMLogOutputWindow.printLog("\(msg)")
    }
    
    static func info(tag: String, _ format : String, _ args: CVarArgType...){
        let s = String(format: format, arguments: args)
        NSLog("\(tag): \(s)")
        HAMLogOutputWindow.printLog("\(s)")
    }
    
    static func debug(tag: String, msg: String){
        NSLog("\(tag) : \(msg)")
        HAMLogOutputWindow.printLog("\(msg)")
    }
    
    static func debug(tag: String, _ format : String, _ args: CVarArgType...){
        let s = String(format: format, arguments: args)
        NSLog("\(tag): \(s)")
        HAMLogOutputWindow.printLog("\(s)")
    }

    static func warning(tag: String, msg: String){
        NSLog("\(tag) : \(msg)")
        HAMLogOutputWindow.printLog("\(msg)")
    }
    
    static func warning(tag: String, _ format : String, _ args: CVarArgType...){
        let s = String(format: format, arguments: args)
        NSLog("\(tag): \(s)")
        HAMLogOutputWindow.printLog("\(s)")
    }

    
    static func error(tag: String, msg: String){
        NSLog("\(tag) : \(msg)")
        HAMLogOutputWindow.printLog("\(msg)")
    }
    
    static func error(tag: String, _ format : String, _ args: CVarArgType...){
        let s = String(format: format, arguments: args)
        NSLog("\(tag): \(s)")
        HAMLogOutputWindow.printLog("\(s)")
    }
}